// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import "@babel/polyfill";
import Vue from "vue";
import axios from "axios";
import App from "./App";
import router from "./router";
import "./plugins/element.js";
import "./assets/CSS/global.css";
import "./assets/iconfont/iconfont.css";
import VeHistogram from "v-charts/lib/histogram.common";
import store from "./store";
// import { Message } from "element-ui";
import $ from "jquery";
import Print from "vue-print-nb";
import VueBarcode from '@xkeshi/vue-barcode'; //导入条形码插件
Vue.component('barcode', VueBarcode);

Vue.use(Print);
Vue.component(VeHistogram.name, VeHistogram);

Vue.config.productionTip = false;
Vue.prototype.$http = axios;
Vue.use(router);
Vue.config.productionTip = false;
//配置请求根路径
// axios.defaults.baseURL = 'http://192.168.220.196:8899'
axios.defaults.baseURL = "/api";
axios.defaults.withCredentials = true;
axios.defaults.crossDomain = true;

axios.interceptors.request.use(config => {
  if (sessionStorage.getItem("User_Code")) {
    var str = sessionStorage.getItem("User_Code")
    console.log('1234567890')
    console.log(str)
    var newStr = str.replace(/"/g, '')
    console.log(newStr)
    config.headers.Authorization = newStr
  }
  return config;
});
// let hasMessage = false
// axios.interceptors.response.use(
//   response => {
//     const res = response.data
//     if (res.code === 5 && router.currentRoute.path !== '/qrcode') {
//       // 代表未登陆 跳转登陆页面
//       if (!hasMessage) {
//         hasMessage = true
//         router.push('/login')
//         Message.info({
//           message: '登陆超时，请重新登陆',
//           onClose: () => {
//             hasMessage = false
//           }
//         })
//       }
//     }
//     return response
//   }
// )
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
